package com.asa.common.widgets;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;


public class ButtonAnim {

    public static AnimatorSet loadDownAnim(View view) {
        AnimatorSet animatorSet = new AnimatorSet();
        ObjectAnimator scaleX1 = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.90f);
        scaleX1.setDuration(120);
        ObjectAnimator scaleY1 = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.90f);
        scaleY1.setDuration(120);
        ObjectAnimator scaleX2 = ObjectAnimator.ofFloat(view, "scaleX", 0.90f, 0.95f);
        scaleX2.setDuration(100);
        ObjectAnimator scaleY2 = ObjectAnimator.ofFloat(view, "scaleY", 0.90f, 0.95f);
        scaleY2.setDuration(100);
        ObjectAnimator scaleX3 = ObjectAnimator.ofFloat(view, "scaleX", 0.95f, 0.90f);
        scaleX3.setDuration(120);
        ObjectAnimator scaleY3 = ObjectAnimator.ofFloat(view, "scaleY", 0.95f, 0.90f);
        scaleY3.setDuration(120);

        animatorSet.setInterpolator(new CubicBezierInterpolator(0.17f, 0f, 0.3f, 1f));
        animatorSet.play(scaleX1).with(scaleY1);
        animatorSet.play(scaleX2).with(scaleY2).after(scaleX1);
        animatorSet.play(scaleX3).with(scaleY3).after(scaleX2);
        return animatorSet;
    }

    public static AnimatorSet loadUpAnim(View view) {
        AnimatorSet animatorSet = new AnimatorSet();
        ObjectAnimator scaleX4 = ObjectAnimator.ofFloat(view, "scaleX", 0.9f, 1f);
        scaleX4.setDuration(120);
        ObjectAnimator scaleY4 = ObjectAnimator.ofFloat(view, "scaleY", 0.9f, 1f);
        scaleY4.setDuration(120);
        ObjectAnimator scaleX5 = ObjectAnimator.ofFloat(view, "scaleX", 1f, 1f);
        scaleX5.setDuration(120);
        ObjectAnimator scaleY5 = ObjectAnimator.ofFloat(view, "scaleY", 1f, 1f);
        scaleY5.setDuration(120);

        animatorSet.setInterpolator(new CubicBezierInterpolator(0.17f, 0f, 0.3f, 1f));
        animatorSet.play(scaleX4).with(scaleY4);
        animatorSet.play(scaleX5).with(scaleY5).after(scaleX4);
        return animatorSet;
    }
}